package com.xiaoyu.izf.service;

import com.xiaoyu.izf.model.Region;
import com.xiaoyu.izf.repository.RegionDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RegionService {

    @Autowired
    private RegionDao regionDao;

    public Region findByRegionId(int regionId){
        return regionDao.findOneByRegionId(regionId);
    }

    public List<Region> findByParentId(int parentId){
        return regionDao.findAllByParentId(parentId);
    }

    public List<Region> provinces(){
        return regionDao.findAllByParentId(1);
    }

    public List<Region> cities(int parentId){
        return regionDao.findAllByParentId(parentId);
    }
}
